package com.study.meng.bigevent.common.utils;


public class ThreadLocalUtil {
    private static final ThreadLocal<Integer> THREAD_LOCAL = new ThreadLocal<>();

    // 存储数据
    public static void setCurrentUser(Integer userId) {
        THREAD_LOCAL.set(userId);
    }

    // 获取数据
    public static <T> T getCurrentUser() {
        return (T) THREAD_LOCAL.get();
    }

    // 清除数据
    public static void remove() {
        THREAD_LOCAL.remove();
    }
}

